<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.js"></script>
    <title>Document</title>
</head>

<body>
    <div id="root">
        <h1 v-text='msg' ref='title'></h1>
        <button @click='show'>获取上方的DOM元素</button>
    </div>
</body>
<script>
    Vue.config.productionTip = false
    new Vue({
        el: '#root',
        data() {
            return {
                msg: '欢迎来到xxx'
            }
        },
        methods: {
            show() {
                console.log(this.$refs.title)
            }
        }
    })
</script>

</html>